<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>字节流字符串转化工具</title>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	</head>
	
	<body>
		<div id="">
			<input type="text" name="s" id="s" value="23" />
			<input type="text" name="a" id="a" value="019E000000002723" />
			<input type="button" name="" id="btn" value="1" onclick="nextBtye()" />
		</div>
		
		<div id="r1" style="width: 500px;height: auto;float: left;border:black solid 2px;">
			
		</div>
		<div id="r2" style="width: 500px;height: auto;float: left;border:black solid 2px;">
			
		</div>
		<script type="text/javascript">
			
			function nextBtye(){
				var s  = $("#s").val().trim();
				var a = $("#a").val().trim();
				console.log(a.length);
				var b1 = "";
				var b2 = "";
				var m = s;
				
				var n1 = 0;
				for (var i = 0; i < a.length/2; i++) {
					b1 += "b[" + m + "] = (byte) 0x" + a.substring(n1, n1+2)+";<br>";
					n1 = n1+2;
					m++;
				}
				m = s;
				var n2 = a.length;
				for (var i = 0; i < a.length/2; i++) {
					b2 += "b[" + m + "] = (byte) 0x" + a.substring(n2-2, n2)+";<br>";
					n2 = n2-2;
					m++;
				}
				//console.log(b1);
				console.log(b2);
				$("#r1").html(b2);
				$("#r2").html(b1);
			}
			$("#a").change(function(){
				var a = $("#a").val().trim();
				console.log(a);
				$("#btn").val(a.length/2);
			});
		</script>
	</body>

</html>